YNQ  YNQ-1.6.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
cmapi.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Copyright (c) 2021 by Visuality Systems, Ltd.
4  *
5  *********************************************************************
6  * FILE NAME : $Workfile:$
7  * ID : $Header:$
8  * REVISION : $Revision:$
9  *--------------------------------------------------------------------
10  * DESCRIPTION : Entire CM - Common library functionality
11  *--------------------------------------------------------------------
12  * MODULE : NQ
13  * DEPENDENCIES :
14  ********************************************************************/
15 
16 #ifndef _CMAPI_H_
17 #define _CMAPI_H_
18 
19 #include "syapi.h" /* system-dependent */
20 #include <cmcommon.h> /* basic types */
21 #include <cmparams.h> /* parameters */
22 #include <cmutils.h> /* more common functionality for all modules */
23 #include <cmlist.h> /* linked list */
24 #include <cmmemory.h> /* dynamic memory */
25 #include <cmselfip.h> /* IP configuration */
26 #include <cmresolver.h> /* name to IP resolver */
27 #include <cmthread.h> /* thread management */
28 #ifdef UD_NQ_INCLUDECODEPAGE
29 #include <cmcp.h> /* Code pages */
30 #endif /* UD_NQ_INCLUDECODEPAGE */
31 #include <cmunicod.h> /* ANSI to UNICODE and v/v */
32 #include <cmstrparse.h> /* string parser */
33 #include <cmstring.h> /* mapping of string manipulation */
34 #include <cmnbapi.h> /* NetBIOS */
35 #include <cmfsapi.h> /* CIFS */
36 #include <cmrpcdef.h> /* DCERPC */
37 #include <cmsdescr.h> /* Security Descriptors */
38 #include <cmvalida.h> /* Validation of cross-dependencies */
39 #include <cmtrace.h> /* traces */
40 #include <cmbufman.h>
41 #ifdef UD_NQ_INCLUDESMBCAPTURE
42 #include <cmcapture.h>
43 #endif /* UD_NQ_INCLUDESMBCAPTURE */
44 #include <udconfig.h>
45 
46 
61 NQ_STATUS cmInit(NQ_UINT32 component);
62 
68 void cmExit(NQ_UINT32 component);
69 
70 #define NQ_CLIENT 0x1
71 #define NQ_SERVER 0x2
72 #define NQ_NDDAEMON 0x4
80 #define NQ_RESOLVER_IPV4 4
81 #define NQ_RESOLVER_IPV6 6
82 #define NQ_RESOLVER_NONE 0
84 #define NQ_RESOLVER_DNS 1
85 #define NQ_RESOLVER_NETBIOS 2
86 #define NQ_RESOLVER_EXTERNAL_METHOD 5
87 #define NQ_RESOLVER_DNS_DC 8
88 #define NQ_RESOLVER_NETBIOS_DC 10
89 #define NQ_RESOLVER_WSD 12
106 typedef struct
107 {
108  void **items; /* a cyclic sorted array of pointers to the memoryPool nodes */
109  CMList memoryPool; /* A list of available unused memory blocks */
110  NQ_UINT currentPosition; /* holds the current position of the next available memory block in the items array */
111  NQ_UINT numberOfItems; /* number of current items in the items array */
112  NQ_UINT32 divider; /* when a new memory block has to be stored in the items array we need to use a formula to keep it sorted.
113  The formula is dependent on a divider, we want to use the same divider for all the items calculations */
114  void *context; /* a context pointer */
116 
124 #define CM_PRODUCT_STRING_LEN 20
125 
126 /* This struct represents the current product information */
127 typedef struct
128 {
129  NQ_CHAR productName[CM_PRODUCT_STRING_LEN]; /* The product name */
130  NQ_CHAR productType[CM_PRODUCT_STRING_LEN]; /* Client Standalone / Client Corporate / Server Standalone / Server Corporate */
131  NQ_CHAR version[CM_PRODUCT_STRING_LEN]; /* The current product version */
133 } CMProductInfo;
134 
141 typedef struct
142 {
148  NQ_INT (*toAnsi) ( NQ_CHAR* outStr, NQ_UINT outLength, const NQ_WCHAR* inWStr, NQ_UINT inLength);
149  NQ_INT (*toUnicode)( NQ_WCHAR* outWStr, NQ_UINT outLength, const NQ_CHAR* inStr, NQ_UINT inLength);
150  NQ_INT (*toUpper) ( NQ_CHAR* dst, const NQ_CHAR* src);
152  void (*ansiToFs) ( NQ_CHAR* str, NQ_INT size, const NQ_BYTE* firstIllegalChar, const NQ_BYTE* anyIllegalChar, NQ_INT numOfFirstIllChars, NQ_INT numOfAnyIllChars);
154  void (*fsToAnsi) ( NQ_CHAR* str, NQ_INT size, const NQ_BYTE* firstIllegalChar, const NQ_BYTE* anyIllegalChar, NQ_INT numOfFirstIllChars, NQ_INT numOfAnyIllChars);
155 
156  const NQ_WCHAR* a2uTab;
161 }
162 CMCodepage;
163 
171 typedef struct
172 {
173 
188  NQ_STATUS (* requestByName)(SYSocketHandle socket, const NQ_WCHAR * name, void * context,
189  const NQ_IPADDRESS * serverIp, NQ_COUNT * numOfSentRequests);
200  NQ_STATUS (* responseByName)(SYSocketHandle socket, NQ_IPADDRESS ** pAddressArray, NQ_INT * numIps, void ** pContext);
215  NQ_STATUS (* requestByIp)(SYSocketHandle socket, const NQ_IPADDRESS * ip, void * context,
216  const NQ_IPADDRESS * serverIp, NQ_COUNT * numOfSentRequests);
227  NQ_STATUS (* responseByIp)(SYSocketHandle socket, const NQ_WCHAR ** pName, void ** pContext);
240 }
242 
245 /* function prototypes */
246 
272 NQ_BOOL cmCodepageAdd(const CMCodepage * codePage);
273 
287 NQ_BOOL cmCodepageRemove(const CMCodepage * codePage);
288 
293 void cmWideCharToMultiByte(NQ_CHAR *strMultiByte, const NQ_WCHAR* strWideChar);
294 
299 void cmMultiByteToWideChar(NQ_WCHAR* strWideChar, const NQ_CHAR *strMultiByte);
300 
317 typedef void (* CMAbstractHasher)(const NQ_BYTE * dataIn, NQ_BYTE * dataOut, NQ_COUNT length);
318 
344 typedef void (* CMAbstractCipher)(const CMBlob * key, const CMBlob * key1, const CMIOBlob dataFragments[], NQ_COUNT numFragments, NQ_BYTE * buffer, NQ_COUNT bufferSize);
345 
372 typedef void (* CMAbstractIOCipher)(const CMBlob * key, const CMBlob * key1, const CMIOBlob dataFragments[], NQ_COUNT numFragments, NQ_BYTE * buffer, NQ_COUNT bufferSize);
373 
400 typedef void (* CMAbstractHasher512)(const CMBlob * key, const CMBlob * key1, const CMIOBlob dataFragments[], NQ_COUNT numFragments, NQ_IOBufPos buffer, NQ_COUNT bufferSize, NQ_BYTE *ctxBuff);
401 
431 typedef void (* CMAbstractCcmEncryption)(const CMBlob * key, const CMBlob * key1, const CMIOBlob * prefix, CMIOBlob * message, NQ_BYTE * auth);
432 
460 typedef NQ_BOOL (* CMAbstractCcmDecryption)(const CMBlob * key, const CMBlob * key1, const CMIOBlob * prefix, CMIOBlob * message, const NQ_BYTE * auth);
461 
462 
495 typedef void (* CMAbstractGcmEncryption)(const CMBlob *key, const CMBlob *key1, const CMIOBlob *prefix, CMIOBlob *message, NQ_BYTE *auth, NQ_BYTE *keyBuffer, NQ_BYTE *encMsgBuffer);
496 
530 typedef NQ_BOOL (* CMAbstractGcmDecryption)(const CMBlob * key, const CMBlob *key1, const CMIOBlob *prefix, CMIOBlob *message, const NQ_BYTE *auth, NQ_BYTE *keyBuffer, NQ_BYTE *msgBuffer);
531 
539 typedef struct
540 {
551 }
553 
560 void cmSetExternalCrypters(const CMCrypterList * crypters);
561 
565 void cmResetExternalCrypters(void);
566 
597 typedef NQ_INT (*CMResolverNameToIpA)(const NQ_CHAR * name, void * ip, NQ_COUNT index);
598 
622 typedef NQ_INT (*CMResolverNameToIp)(const NQ_WCHAR * name, void * ip, NQ_COUNT index);
623 
639 typedef NQ_BOOL (*CMResolverIpToNameA)(NQ_CHAR * name, const void * ip, NQ_INT ipType);
640 
655 typedef NQ_BOOL (*CMResolverIpToName)(NQ_WCHAR * name, const void * ip, NQ_INT ipType);
656 
691 
726 
751 const NQ_WCHAR * cmResolverGetHostName(const NQ_IPADDRESS * ip);
752 
783 const NQ_IPADDRESS * cmResolverGetHostIps(const NQ_WCHAR * dnsList, const NQ_WCHAR * host, NQ_INT * numIps);
784 
811 const NQ_WCHAR * cmResolverGetDCName(const NQ_WCHAR * domain, const NQ_WCHAR * dnsList, NQ_INT * numDCs);
812 
842 void cmResolverEnableMethod(NQ_INT type, NQ_BOOL unicast, NQ_BOOL multicast);
843 
864 
884 
905 void cmDnsSetServersA(const NQ_CHAR * servers);
906 
918 void cmDnsSetServers(const NQ_WCHAR * servers);
919 
930 
937 
956 void cmNetBiosSetWinsA(const NQ_CHAR * servers);
957 
970 void cmNetBiosSetWins(const NQ_WCHAR * servers);
971 
980 
987 
1000 NQ_STATUS cmDnsSetDomainA(const NQ_CHAR * domainName);
1001 
1014 NQ_STATUS cmDnsSetDomain(const NQ_WCHAR * domainName);
1015 
1028 
1038 
1041 #endif /* _CMAPI_H_ */
NQ_COUNT cmNetBiosGetNumWinsServers(void)
void cmDnsSetServers(const NQ_WCHAR *servers)
NQ_STATUS cmDnsSetDomainA(const NQ_CHAR *domainName)
CMAbstractCcmEncryption aes128ccmEncryption
Definition: cmapi.h:547
NQ_BOOL(* CMResolverIpToName)(NQ_WCHAR *name, const void *ip, NQ_INT ipType)
Definition: cmapi.h:655
NQ_STATUS cmNetBiosNameReload(void)
CMAbstractHasher512 sha512
Definition: cmapi.h:546
NQ_BOOL cmCodepageRemove(const CMCodepage *codePage)
NQ_STATUS cmInit(NQ_UINT32 component)
unsigned int NQ_UINT
Definition: udapi.h:29
NQ_BOOL cmResolverRegisterExternalMethod(const CMResolverRegisteredMethodDescription *pMethod)
void(* CMAbstractHasher)(const NQ_BYTE *dataIn, NQ_BYTE *dataOut, NQ_COUNT length)
Definition: cmapi.h:317
NQ_IPADDRESS4 cmNetBiosGetWins(NQ_COUNT winsID)
void cmWideCharToMultiByte(NQ_CHAR *strMultiByte, const NQ_WCHAR *strWideChar)
NQ_INT(* CMResolverNameToIp)(const NQ_WCHAR *name, void *ip, NQ_COUNT index)
Definition: cmapi.h:622
void cmResolverEnableMethod(NQ_INT type, NQ_BOOL unicast, NQ_BOOL multicast)
Definition: cmapi.h:106
void(* CMAbstractGcmEncryption)(const CMBlob *key, const CMBlob *key1, const CMIOBlob *prefix, CMIOBlob *message, NQ_BYTE *auth, NQ_BYTE *keyBuffer, NQ_BYTE *encMsgBuffer)
Definition: cmapi.h:495
CMProductInfo * cmGetCurrentProductInformation(void)
Definition: cmapi.h:141
void cmExit(NQ_UINT32 component)
NQ_UINT32 NQ_IPADDRESS4
Definition: udapi.h:49
NQ_STATUS cmDnsSetDomain(const NQ_WCHAR *domainName)
#define SYSocketHandle
Definition: syopsyst.h:331
void ** items
Definition: cmapi.h:108
const NQ_IPADDRESS * cmResolverGetHostIps(const NQ_WCHAR *dnsList, const NQ_WCHAR *host, NQ_INT *numIps)
NQ_UINT32 divider
Definition: cmapi.h:112
void cmMultiByteToWideChar(NQ_WCHAR *strWideChar, const NQ_CHAR *strMultiByte)
NQ_UINT NQ_COUNT
Definition: udapi.h:32
NQ_UINT16 NQ_WCHAR
Definition: udapi.h:45
NQ_UINT32 checksum
Definition: cmapi.h:132
unsigned char NQ_BYTE
Definition: udapi.h:27
CMAbstractCipher md5
Definition: cmapi.h:542
const NQ_WCHAR * cmResolverGetHostName(const NQ_IPADDRESS *ip)
#define CM_PRODUCT_STRING_LEN
Definition: cmapi.h:124
CMAbstractHasher md4
Definition: cmapi.h:541
NQ_UINT numberOfItems
Definition: cmapi.h:111
NQ_BOOL(* CMAbstractCcmDecryption)(const CMBlob *key, const CMBlob *key1, const CMIOBlob *prefix, CMIOBlob *message, const NQ_BYTE *auth)
Definition: cmapi.h:460
CMAbstractGcmDecryption aes128gcmDecryption
Definition: cmapi.h:550
NQ_UINT currentPosition
Definition: cmapi.h:110
void(* CMAbstractCcmEncryption)(const CMBlob *key, const CMBlob *key1, const CMIOBlob *prefix, CMIOBlob *message, NQ_BYTE *auth)
Definition: cmapi.h:431
NQ_IPADDRESS * cmDnsGetServer(NQ_COUNT dnsID)
void(* CMAbstractCipher)(const CMBlob *key, const CMBlob *key1, const CMIOBlob dataFragments[], NQ_COUNT numFragments, NQ_BYTE *buffer, NQ_COUNT bufferSize)
Definition: cmapi.h:344
CMAbstractGcmEncryption aes128gcmEncryption
Definition: cmapi.h:549
Definition: udapi.h:138
void cmResolverSetExternalA(CMResolverNameToIpA nameToIp, CMResolverIpToNameA ipToName)
NQ_BOOL(* CMResolverIpToNameA)(NQ_CHAR *name, const void *ip, NQ_INT ipType)
Definition: cmapi.h:639
CMList memoryPool
Definition: cmapi.h:109
void cmNetBiosSetWins(const NQ_WCHAR *servers)
void(* CMAbstractIOCipher)(const CMBlob *key, const CMBlob *key1, const CMIOBlob dataFragments[], NQ_COUNT numFragments, NQ_BYTE *buffer, NQ_COUNT bufferSize)
Definition: cmapi.h:372
CMAbstractCcmDecryption aes128ccmDecryption
Definition: cmapi.h:548
CMAbstractCipher hmacmd5
Definition: cmapi.h:543
void cmResetExternalCrypters(void)
NQ_BOOL cmResolverUpdateExternalMethodsPriority(NQ_INT requiredPriority)
Definition: cmapi.h:539
int NQ_INT
Definition: udapi.h:28
void cmResolverSetExternal(CMResolverNameToIp nameToIp, CMResolverIpToName ipToName)
Definition: cmapi.h:127
CMAbstractIOCipher sha256
Definition: cmapi.h:544
void(* CMAbstractHasher512)(const CMBlob *key, const CMBlob *key1, const CMIOBlob dataFragments[], NQ_COUNT numFragments, NQ_IOBufPos buffer, NQ_COUNT bufferSize, NQ_BYTE *ctxBuff)
Definition: cmapi.h:400
const NQ_WCHAR * cmResolverGetDCName(const NQ_WCHAR *domain, const NQ_WCHAR *dnsList, NQ_INT *numDCs)
void cmDnsSetServersA(const NQ_CHAR *servers)
void cmSetExternalCrypters(const CMCrypterList *crypters)
void cmNetBiosSetWinsA(const NQ_CHAR *servers)
NQ_BOOL(* CMAbstractGcmDecryption)(const CMBlob *key, const CMBlob *key1, const CMIOBlob *prefix, CMIOBlob *message, const NQ_BYTE *auth, NQ_BYTE *keyBuffer, NQ_BYTE *msgBuffer)
Definition: cmapi.h:530
int NQ_BOOL
Definition: udapi.h:30
NQ_INT(* CMResolverNameToIpA)(const NQ_CHAR *name, void *ip, NQ_COUNT index)
Definition: cmapi.h:597
const NQ_WCHAR * a2uTab
Definition: cmapi.h:156
char NQ_CHAR
Definition: udapi.h:26
NQ_COUNT cmDnsGetNumDnsServers(void)
NQ_BOOL cmCodepageAdd(const CMCodepage *codePage)
NQ_IPADDRESS * serverIP
Definition: cmapi.h:185
unsigned long NQ_UINT32
Definition: udapi.h:43
NQ_UINT32 timeout
Definition: cmapi.h:183
void * context
Definition: cmapi.h:114
NQ_INT activationPriority
Definition: cmapi.h:174
CMAbstractIOCipher aes128cmac
Definition: cmapi.h:545
NQ_INT NQ_STATUS
Definition: udapi.h:47
NQ_INT id
Definition: cmapi.h:143